#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	long long n,l,r,mn=0;
	scanf("%lld%lld%lld",&n,&l,&r);
	if((r-l)>=n){
		printf("%lld",n-1);
		return 0;
	}
	else{
		mn=min(r-l+(l%n),n-1);
		printf("%lld",mn);
	}
	return 0;
}
